<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>转账</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
  <!-- 导航栏同dashboard.html -->
  <div class="container mt-4">
    <h3>转账</h3>
    <form>
      <div class="mb-3">
        <label for="fromCard" class="form-label">转出卡号</label>
        <input type="text" class="form-control" id="fromCard" required>
      </div>
      <div class="mb-3">
        <label for="toCard" class="form-label">转入卡号</label>
        <input type="text" class="form-control" id="toCard" required>
      </div>
      <div class="mb-3">
        <label for="amount" class="form-label">转账金额</label>
        <input type="number" class="form-control" id="amount" required>
      </div>
      <button type="submit" class="btn btn-primary">确认转账</button>
    </form>
    <input id="fromCardID" placeholder="转出卡号"><input id="toCardID" placeholder="转入卡号"><input id="amount" placeholder="金额"><button onclick="transfer()">转账</button>
  </div>
  <script src="/static/js/main.js"></script>
  <script>
  async function transfer() {
    const fromCardID = document.getElementById('fromCardID').value;
    const toCardID = document.getElementById('toCardID').value;
    const amount = document.getElementById('amount').value;
    const res = await fetch('/api/customer/transfer', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ fromCardID, toCardID, amount })
    });
    const data = await res.json();
    if (data.success) {
      alert('转账成功');
    } else {
      alert(data.error || '转账失败');
    }
  }
  </script>
</body>
</html>